package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzDeptsync;
import com.ruoyi.system.service.IDzDeptsyncService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 组织同步Controller
 * 
 * @author ruoyi
 * @date 2022-10-31
 */
@RestController
@RequestMapping("/system/deptsync")
public class DzDeptsyncController extends BaseController
{
    @Autowired
    private IDzDeptsyncService dzDeptsyncService;

    /**
     * 查询组织同步列表
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzDeptsync dzDeptsync)
    {
        startPage();
        List<DzDeptsync> list = dzDeptsyncService.selectDzDeptsyncList(dzDeptsync);
        return getDataTable(list);
    }

    /**
     * 导出组织同步列表
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:export')")
    @Log(title = "组织同步", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzDeptsync dzDeptsync)
    {
        List<DzDeptsync> list = dzDeptsyncService.selectDzDeptsyncList(dzDeptsync);
        ExcelUtil<DzDeptsync> util = new ExcelUtil<DzDeptsync>(DzDeptsync.class);
        util.exportExcel(response, list, "组织同步数据");
    }

    /**
     * 获取组织同步详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:query')")
    @GetMapping(value = "/{zzId}")
    public AjaxResult getInfo(@PathVariable("zzId") Long zzId)
    {
        return AjaxResult.success(dzDeptsyncService.selectDzDeptsyncByZzId(zzId));
    }

    /**
     * 新增组织同步
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:add')")
    @Log(title = "组织同步", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzDeptsync dzDeptsync)
    {
        return toAjax(dzDeptsyncService.insertDzDeptsync(dzDeptsync));
    }

    /**
     * 修改组织同步
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:edit')")
    @Log(title = "组织同步", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzDeptsync dzDeptsync)
    {
        return toAjax(dzDeptsyncService.updateDzDeptsync(dzDeptsync));
    }

    /**
     * 删除组织同步
     */
    @PreAuthorize("@ss.hasPermi('system:deptsync:remove')")
    @Log(title = "组织同步", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zzIds}")
    public AjaxResult remove(@PathVariable Long[] zzIds)
    {
        return toAjax(dzDeptsyncService.deleteDzDeptsyncByZzIds(zzIds));
    }
}
